﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Diagnostics.Contracts;

namespace Isuka.Auxiliaries
{
    public static class SerializationHelper
    {
        public static T GetValue<T>(this SerializationInfo info, string name)
        {
            Contract.Requires(info != null);
            Contract.Requires(!String.IsNullOrEmpty(name));

            return (T)info.GetValue(name, typeof(T));
        }

        public static void InitValue<T>(this SerializationInfo info, string name, out T value)
        {
            Contract.Requires(info != null);
            Contract.Requires(!String.IsNullOrEmpty(name));

            value = (T)info.GetValue(name, typeof(T));
        }
    }
}
